import DList from "@/components/dlist";
import yz_uploader from "components/ui_components/yz_uploader";
export default {
  data() {
    return {
      imgList: [],
      overlayShow: false,
      signedShow: false,
      express_sn: "",
      deduct_love: "",
      buy_button: {},
      basic_info: {},
    };
  },
  activated() {
    this.imgList = [];
    this.overlayShow = false;
    this.signedShow = false;
    this.express_sn = "";
    this.deduct_love = "";
    this.buy_button = {};
    this.basic_info = {};
    this.express_sn = this.$route.params.express_sn;
    this.getData();
    this.basic_info = JSON.parse(localStorage.getItem("yz_basic_info")) || {};
  },
  methods: {
    inputimg(imgVal) {
      // console.log(imgVal,'imgValimgVal');
    },
    async getData() {
      let { data, result, msg } = await $http.post("plugin.third-logistics.frontend.modules.scan.controllers.validate.index", { express_sn: this.express_sn });
      if (result) {
        this.deduct_love = data.deduct_love;
        this.express_sn = data.express_sn;
        this.buy_button = data.buy_button;
      } else {
        this.$toast(msg);
      }
    },
    async confirm() {
      let { data, result, msg } = await $http.post("plugin.third-logistics.frontend.modules.scan.controllers.confirm.index", {
        express_sn: this.express_sn,
        image_url: this.imgList.length ? this.imgList[0] : ""
      });
      if (result) {
        this.signedShow = true;
      } else {
        if(data.love == 1) {
          this.overlayShow = true;
        }else {
          this.$toast(msg);
        }
      }
    },
    clickBuyButton(web_link) {
      window.location.href = web_link;
    },
    closeOverlayShow() {
      this.$router.push(
        this.fun.getUrl("expressSignature", {})
      );
    }
  },
  components: { DList , yz_uploader }
};
